package org.example.hanying.entity;

import java.util.ArrayList;
import java.util.List;

public class ZiTiao {

    private String zimu;

    private String fanti;

    private String pinyin;

    private String lingjian;

    private String liangci;

    public String getLiangci() {
        return liangci;
    }

    public void setLiangci(String liangci) {
        this.liangci = liangci;
    }

    public String getZimu() {
        return zimu;
    }

    public void setZimu(String zimu) {
        this.zimu = zimu;
    }

    public String getFanti() {
        return fanti;
    }

    public void setFanti(String fanti) {
        this.fanti = fanti;
    }

    public String getPinyin() {
        return pinyin;
    }

    public void setPinyin(String pinyin) {
        this.pinyin = pinyin;
    }

    public String getLingjian() {
        return lingjian;
    }

    public void setLingjian(String lingjian) {
        this.lingjian = lingjian;
    }

    public List<YiXiang> getYixiangList() {
        return yixiangList;
    }

    public void setYixiangList(List<YiXiang> yixiangList) {
        this.yixiangList = yixiangList;
    }

    private List<YiXiang> yixiangList = new ArrayList<YiXiang>();

    public String toString(){
        StringBuilder sb = new StringBuilder();
        sb.append("<词条>");
        if(zimu != null && !"".equals(zimu)){
            if(zimu.trim().length()==1) {
                sb.append("<字目>").append(zimu.trim()).append("</字目>");
            }else{
                sb.append("<词目>").append(zimu.replaceAll("[【】]","").trim()).append("</词目>");
            }
        }
        if(fanti != null && !"".equals(fanti)){
            sb.append("<繁体>").append(fanti.trim()).append("</繁体>");
        }
        if(pinyin != null && !"".equals(pinyin)){
            sb.append("<拼音>").append(pinyin.replace("ɡ","g").replace("ɑ","a").trim()).append("</拼音>");
        }

        if(liangci != null && !"".equals(liangci)){
            sb.append("<量词>").append(liangci.trim()).append("</量词>");
        }

        for(int i=0; i<yixiangList.size(); i++){
            sb.append(yixiangList.get(i).toString());
        }
        if(lingjian != null && !"".equals(lingjian)){
            sb.append("<另见>").append(lingjian).append("</另见>");
        }
        sb.append("</词条>");
        return sb.toString();
    }
}
